import $ from './library/jquery.js';
$(function () {
    let loginUser = $('#loginUser');
    let loginPass = $('#loginPass');
    let loginBtn = $('#loginBtn');

    loginBtn.on('click', function (ev) {
        ev.preventDefault();

        $.ajax({
            type: "get",
            url: "../../interface/login.php",
            data: {
                username: loginUser.val(),
                password: loginPass.val()
            },
            dataType: "json"
        }).then(function (data) {
            if (data.success) {
                alert(data.msg);
                sessionStorage.setItem('username', loginUser.val())
                location.href = '../html/index.html';
            } else {
                alert(data.msg);
                location.reload();
            }
        }).catch(function (xhr) {
            console.log(xhr.status);
        });

    })

})